import { IOpenScopePluginMenuItem } from "./IOpenScopePluginMenuItem";
import { IPluginInfo } from "./IPluginInfo";
import { IRadarRenderData } from "./IRenderData";

export interface IOpenScopePluginBase {
    /**
     * Call this method to invoke redraw process for radar screen
     */
    invokeRadarRedraw: () => void;
    /**
     * Fetch can only be done by this method, do not use internal fetch to avoid permission problem.
     * @param _url
     * @param _init
     */
    fetch: (_url: URL | Request | string, _init?: RequestInit) => Promise<Response>;
    /**
     * Get render data instance of active radar screen.
     */
    getRenderDataInstance: () => IRadarRenderData;
    /**
     * Call this method to read a text file.
     * @param uri
     */
    readTextFile: (uri: string) => Promise<string>;
    /**
     * Call this method to read a file into binary.
     * @param uri
     */
    readBufferFile: (uri: string) => Promise<ArrayBuffer>;
    /**
     * Call this method to read a .cur cursor file into base64 image.
     * @param uri
     */
    readCurFileToBase64: (uri: string) => Promise<string>;
    setCurFileAsCursor: (uri: string) => Promise<void>;

    /**
     * This method was called on every render data change.
     * @param data
     */
    onRenderDataUpdate(data: IRadarRenderData): void;

    /**
     * This method was called on every drawing process, you can update your content on the screen in this method.
     * @param context
     * @param scaleIndex
     */
    onRadarFrame(context: CanvasRenderingContext2D, scaleIndex: number): void;

    /**
     * This method will be called once the plugin is completely loaded. You may want to initialize other stuff in this method.
     * @param workingDir plugin working directory
     */
    onInitialized(workingDir: string): void;

    /**
     * If you provide any functions by menu, return them in this method.
     */
    onAcquireMenu(): Array<IOpenScopePluginMenuItem>;

    /**
     * Provides some basic information about you and your plugin.
     */
    onAcquirePluginInformation(): IPluginInfo;
}